﻿using UnityEngine;
using System.Collections;

public class LegecyTestCode : MonoBehaviour {

    public float curTime = 0f;
    public float playTime = 5f;
   // Animation animation;
    int animationNum = 23;
    public string[] animationName;

	// Use this for initialization
	void Start () {
       // animation = transform.GetComponent<Animation>();
        animationNum = animation.GetClipCount();
        animation.wrapMode = WrapMode.Loop;

	}
	
	// Update is called once per frame
	void Update () {
        curTime += Time.deltaTime;
        int curTimeInt = (int)Mathf.Floor(curTime/playTime);
        int index = curTimeInt % (animationNum);
        if (index > 22)
            curTime = 0f;

        string isPlayingAnimation = animationName[index];

       // Debug.Log(curTimeInt);
        if (animation.IsPlaying(isPlayingAnimation) == false)
        {
            
            animation.CrossFade(isPlayingAnimation);
        }
	}
}
